package com.dev.security.login.service;

import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;

import com.dev.security.login.beans.LoginSource;
import com.dev.security.login.beans.LoginUser;
import com.dev.security.login.util.LoginConstants;

/**
 * 校验执行
 * @author <b>DEVILIVED</b>
 * <br/>E-Mail：3375758@qq.com
 * <br/>创建时间： 2014年6月28日 下午10:31:50 
 * @version V1.0
 */
public class ValidateInvocation {

	private Iterator<ValidateFilter> filters;
	
	private HttpServletRequest request;
	
	private LoginUser loginUser;
	
	private LoginSource source;
	
	public ValidateInvocation(
			Iterator<ValidateFilter> filters, 
			HttpServletRequest request, 
			LoginUser loginUser, 
			LoginSource source) {
		this.filters = filters;
		this.request = request;
		this.loginUser = loginUser;
		this.source = source;
	}
	/**
	 * 执行
	 * @return
	 */
	public int invoke() {
		if(filters.hasNext()) {
			return filters.next().filter(this);
		}
		return LoginConstants.VALIDATE_TRANSIT;
	}
	
	public HttpServletRequest getRequest() {
		return request;
	}
	public LoginUser getLoginUser() {
		return loginUser;
	}
	
	public LoginSource getLoginSource() {
		return source;
	}
	
}